import request from '@/utils/request';
import { TableListParams } from './data';
import * as RequestHelper from '@/helpers/RequestHelper';

export async function queryRule(params?: TableListParams) {
  // @ts-ignore
  return request('/api/admin/config/index', { params }).then(response => {
    return RequestHelper.formatCurrentStateData(response)
  });
}
export async function queryListRule(params?: TableListParams) {
  // @ts-ignore
  return request('/api/admin/assetfile/index', { params }).then(response => {
    return RequestHelper.formatCurrentStateData(response)
  });
}
export async function removeRule(params: { key: number[] }) {
  return request('/api/admin/assetfile/destroy', {
    method: 'POST',
    data: {
      ...params,
      method: 'delete',
    },
  });
}

export async function addRule(params: TableListParams) {
  return request('/api/admin/config/store_new', {
    method: 'POST',
    data: {
      ...params,
      method: 'store',
    },
  });
}

export async function updateRule(params: TableListParams) {
  return request('/api/admin/config/update', {
    method: 'POST',
    data: {
      ...params,
      method: 'update',
    },
  });
}
